home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / tiff / libtiff / README < prev    next >
Text File  |  1992-02-18  |  8KB  |  164 lines

  1. $Header: /usr/people/sam/tiff/libtiff/RCS/README,v 1.14 92/02/19 14:04:31 sam Exp $
  2.  
  3. Configuration Comments:
  4. ----------------------
  5. Aside from the compression algorithm support, there are
  6. configuration-related defines that you can set in the Makefile:
  7.  
  8. COLORIMETRY_SUPPORT
  9.         if this is defined, support for the colorimetry
  10.         tags will be compiled in.
  11. JPEG_SUPPORT    if this is defined, support for the JPEG-related
  12.         tags will be compiled in.  Note that at the present
  13.         time the JPEG compression support is not included.
  14. YCBCR_SUPPORT    if this is defined, support for the YCbCr-related
  15.         tags will be compiled in.  Note that you'll want
  16.         YCBCR support for JPEG compression+decompression.
  17. CMYK_SUPPORT    if this is defined, support for the CMYK-related
  18.         tags will be compiled in.
  19. MMAP_SUPPORT    if this is set, and OS support exists for memory
  20.         mapping files, then the library will try to map
  21.         a file if it is opened for reading.  If mmap does
  22.         not exist on your system, or the mmap call fails
  23.         on the file, then the normal read system calls are
  24.         used.  It is not clear how useful this facility is.
  25.  
  26. By default, the above are not defined.
  27.  
  28. Portability Comments:
  29. --------------------
  30. I run this code on SGI machines (big-endian, MIPS CPU, 32-bit ints,
  31. IEEE floating point).  Makefiles exist for other platforms that the
  32. code runs on -- this work has mostly been done by other people.
  33. I've also been told that the code runs on Macintosh and PC-based
  34. systems, although I don't know the particulars.
  35.  
  36. In general, I promise only that the code runs on SGI machines.
  37. I will, however, gladly take back fixes to make it work on other
  38. systems -- when the changes are reasonable unobtrusive.
  39.  
  40. I've tried to isolate as many of the UNIX-dependencies as possible in
  41. two files: tiffcompat.h and tif_compat.c.  There are still some problems
  42. with the use of lseek().  I personally don't care to devote
  43. much effort to making the code work (untouched) on lots of non-UNIX
  44. platforms.
  45.  
  46. Machine dependencies such as byte order are determined on the
  47. fly and do not need to be specified.
  48.  
  49. Three general portability-related defines are:
  50.     USE_VARARGS        define as 0 or 1 to select between the use of
  51.             varargs.h and stdarg.h; i.e.  -DUSE_VARARGS=0
  52.             means use stdarg.h
  53.     USE_PROTOTYPES    define as 0 or 1 to select function declarations
  54.             with parameter types
  55.     USE_CONST        if your compiler defines __STDC__ or __EXTENSIONS__,
  56.             but does not support const, define this as 0,
  57.             otherwise leave it alone
  58.     BSDTYPES        define this if your system does NOT define the
  59.             usual 4BSD typedefs
  60. If you compile the code with prototypes (USE_PROTOTYPES=1), then
  61. you must have USE_VARARGS=0.
  62.  
  63. Beware that if __STDC__ is defined and the USE_* symbols are
  64. NOT defined, then compat.h defines:
  65.     USE_PROTOTYPES    1
  66.     USE_VARARGS        0
  67.     USE_CONST        1
  68.  
  69. General Comments:
  70. ----------------
  71. The library is designed to hide as much of the details of TIFF as
  72. possible.  In particular, TIFF directories are read in their entirety
  73. into an internal format.  This means that only the tags known by the
  74. library are available to a user and that certain tag data may be
  75. maintained that a user doesn't care about (e.g. transfer function
  76. tables).
  77.  
  78. To add support for a new directory tag the following changes will be
  79. needed:
  80.  
  81. 1. Define the tag in tiff.h.
  82. 2. Add a field to the directory structure in tiffioP.h and define a
  83.    FIELD_* bit.
  84. 3. Add an entry in the FieldInfo array defined at the top of tiff_dirinfo.c.
  85. 4. Add entries in TIFFSetField() and TIFFGetField1() for the new tag.
  86. 5. (optional) If the value associated with the tag is not a scalar value
  87.    (e.g. the array for TransferFunction), then add the appropriate
  88.    code to TIFFReadDirectory() and TIFFWriteDirectory().  You're best
  89.    off finding a similar tag and cribbing code.
  90. 6. Add support to TIFFPrintDirectory() in tiff_print.c to print the
  91.    tag's value.
  92.  
  93. To add support for a compression algorithm:
  94.  
  95. 1. Define the tag value in tiff.h.
  96. 2. Edit the file tiff_compress.c to add an entry to the
  97.    CompressionSchemes[] array.
  98. 3. Create a file with the compression scheme code, by convention files
  99.    are named tif_*.c (except perhaps on System V where the tif_ prefix
  100.    pushes some filenames over 14 chars.
  101. 4. Edit the Makefile to include the new source file.
  102.  
  103. A compression scheme, say foo, can have up to 10 entry points:
  104.  
  105. TIFFfoo(tif)        /* initialize scheme and setup entry points in tif */
  106. fooPreDecode(tif)    /* called once per strip, after data is read,
  107.                but before the first row in a strip is decoded */
  108. fooDecode*(tif, bp, cc, sample)/* decode cc bytes of data into the buffer */
  109.     fooDecodeRow(...)    /* called to decode a single scanline */
  110.     fooDecodeStrip(...)    /* called to decode an entire strip */
  111.     fooDecodeTile(...)    /* called to decode an entire tile */
  112. fooPreEncode(tif)    /* called once per strip/tile, before the first row in
  113.                a strip is encoded */
  114. fooEncode*(tif, bp, cc, sample)/* encode cc bytes of user data (bp) */
  115.     fooEncodeRow(...)    /* called to decode a single scanline */
  116.     fooEncodeStrip(...)    /* called to decode an entire strip */
  117.     fooEncodeTile(...)    /* called to decode an entire tile */
  118. fooPostEncode(tif)    /* called once per strip/tile, just before data is written */
  119. fooSeek(tif, row)    /* seek forwards row scanlines from the beginning
  120.                of a strip (row will always be >0 and <rows/strip */
  121. fooCleanup(tif)        /* called when compression scheme is replaced by user */
  122.  
  123. Note that the encoding and decoding variants are only needed when
  124. a compression algorithm is dependent on the structure of the data.
  125. For example, Group 3 2D encoding and decoding maintains a reference
  126. scanline.  The sample parameter identifies which sample is to be
  127. encoded or decoded if the image is orgnanized with PlanarConfig=2
  128. (separate planes).  This is important for algorithms such as JPEG.
  129. If PlanarConfig=1 (interleaved), then sample will always be 0.
  130.  
  131. The library handles most I/O buffering.  There are two data buffers
  132. when decoding data: a raw data buffer that holds all the data in a
  133. strip, and a user-supplied scanline buffer that compression schemes
  134. place decoded data into.  When encoding data the data in the
  135. user-supplied scanline buffer is encoded into the raw data buffer (from
  136. where it's written).  Decoding routines should never have to explicitly
  137. read data -- a full strip/tile's worth of raw data is read and scanlines
  138. never cross strip boundaries.  Encoding routines must be cognizant of
  139. the raw data buffer size and call TIFFFlushData1() when necessary.
  140. Note that any pending data is automatically flushed when a new strip/tile is
  141. started, so there's no need do that in the tif_postencode routine (if
  142. one exists).
  143.  
  144. The variables tif_rawcc, tif_rawdata, and tif_rawcp in a TIFF structure
  145. are associated with the raw data buffer.  tif_rawcc must be non-zero
  146. for the library to automatically flush data.  The variable
  147. tif_scanlinesize is the size a user's scanline buffer should be.  The
  148. varaible tif_tilesize is the size of a tile for tiled images.  This
  149. should not normally be used by compression routines, except where it
  150. relates to the compression algorithm.  That is, the cc parameter to the
  151. tif_decode* and tif_encode* routines should be used in terminating
  152. decompression/compression.  This ensures these routines can be used,
  153. for example, to decode/encode entire strips of data.
  154.  
  155. In general, if you have a new compression algorithm to add, work from
  156. the code for an existing routine.  In particular, tiff_dumpmode.c has
  157. the trivial code for the "nil" compression scheme, tiff_packbits.c is a
  158. simple byte-oriented scheme that has to watch out for buffer
  159. boundaries, and tiff_lzw.c has the LZW scheme that has the most
  160. complexity -- it tracks the buffer boundary at a bit level.
  161.  
  162. Of course, using a private compression scheme (or private tags) limits
  163. the portability of your TIFF files.
  164.